<?
session_start();
if(!session_is_registered("myusername")){
    header("location:index.php");
}
else{
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf8"/>
        <title>Kartapuce - Projet BDD FPMs >> Aide</title>
        <link rel="stylesheet" href="./mystyle.css" type="text/css" media="screen" />
    </head>
    <body>
        <small>
            <b>Logged as:
                <?
                session_start();
                print $myusername;
                ?>
                <A HREF="./logout.php">Log out</A>

            </b>
        </small>

        <div id="conteneur" align="center" class="conteneur">
            <div align="center" class="conteneurdessus">
                <img src="img/banner.png" width="600" height="185" alt="banner" border="0"/>
            </div>
        </div>
        <center>
            <div id="conteneurdessus" align="center" class="conteneurdessus">
                <table border="0" cellspacing="10">
                    <td>
                        <A HREF="./boutique.php"><img src="img/boutique.png" width="138" height="39" alt="boutique" border="0"/>
                        </A>
                    </td>
                    <td>
                        <A HREF="./compte.php"><img src="img/compte.png" width="138" height="39" alt="compte" border="0"/>
                        </A>
                    </td>
                    <td>
                        <A HREF="./commandes.php"><img src="img/commandes.png" width="138" height="39" alt="commandes" border="0"/>
                        </A>
                    </td>
                    <td>
                        <A HREF="./panier.php"><img src="img/panier.png" width="138" height="39" alt="panier" border="0"/>
                        </A>
                    </td>
                    <td>
                        <A HREF="./accueil.php"><img src="img/accueil.png" width="138" height="39" alt="accueil" border="0"/>
                        </A>
                    </td>
                </table>

            </div>



            <div id='colonne1' align='left' class='colonnem'>
            <?
            include 'connect_db.php';          
  
            echo ' <font face="New Century" size="5" color="black">&nbsp<u><b>Données d&#39identification</b></u></font> ';


            $sql0="SELECT ville_idville as 'ID' FROM db_clients WHERE email='".$myusername."'";
            $res10 = mysql_query($sql0);
            $row10 = mysql_fetch_row($res10);
            
            if ($row10[0]=="0")
            {
                $sql00 = "INSERT INTO db_ville (cp,nom) VALUES ('','')";
                $res00 = mysql_query($sql00);
                $sql01 = "SELECT idville FROM db_ville WHERE nom=''";
                $res01 = mysql_query($sql01);
                $row01 = mysql_fetch_row($res01);
                //echo 'Numéro de ligne créé: '.$row01[0];
                $sql02 = "UPDATE db_clients SET  ville_idville='".$row01[0]."' WHERE email='".$myusername."'";
                $res02 = mysql_query($sql02);
                echo '<dd><br><br><b> Nouveau client:</b>';
                echo '<form><input type="button" value="Saisir les données" OnClick=window.location.replace("saisie_user.php")></form></dd>';
            }
            else
            {


            

            $sql="SELECT db_clients.email, db_clients.nom, db_clients.telephone, db_clients.num, db_clients.rue, db_clients.ville_idville, db_ville.nom as 'ville', db_ville.cp as 'cp' FROM db_clients inner join db_ville on db_clients.ville_idville=db_ville.idville WHERE email='".$myusername."'";
            $result=mysql_query($sql);

               while($data = mysql_fetch_assoc($result))
                    {
                       echo '<blockquote><b><li type=circle>Identifiant: </b>'.$data['email'].'<br><b><li type=circle>Nom: </b>'.$data['nom'].'<br><b><li type=circle>Téléphone: </b>'.$data['telephone'].'<br><b><li type=circle>Adresse: </b>'.$data['rue'].', '.$data['num'].' à '.$data['cp'].' '.$data['ville'].'<br></blockquote>';
                    }
           // echo '<dd><input type="submit" name="Submit" value="Modifier les données"></dd>';
            echo '<dd><form><input type="button" value="Modifier les données" OnClick=window.location.replace("saisie_user.php")></form></dd><br>';
            
            }




            mysql_close($link);

            ?>
            </div>



                      
        </center>
    </body>
</html>